﻿@inject IStringLocalizer<Uploads> Localizer

<div class="row g-3">
    <div class="col-12 col-sm-6">
        <label for="text1" class="form-label">@Localizer["UploadNormalLabelName"]</label>
        <input id="text1" class="form-control">
    </div>
    <div class="col-12 col-sm-6">
        <label for="text2" class="form-label">@Localizer["UploadNormalLabelAdress"]</label>
        <input id="text2" class="form-control">
    </div>
    <div class="col-12">
        <label for="text3" class="form-label">@Localizer["UploadNormalLabelPhoto"]</label>
        <InputUpload TValue="string" ShowDeleteButton="true" OnChange="@OnFileChange" OnDelete="@OnFileDelete"></InputUpload>
    </div>
</div>
<ConsoleLogger @ref="Logger" class="mt-3" />

@code {
    [NotNull]
    private ConsoleLogger? Logger { get; set; }

    private Task OnFileChange(UploadFile file)
    {
        // 未真正保存文件
        // file.SaveToFile()
        Logger.Log($"{file.File!.Name} {Localizer["UploadsSuccess"]}");
        return Task.FromResult("");
    }

    private Task<bool> OnFileDelete(UploadFile item)
    {
        Logger.Log($"{item.OriginFileName} {Localizer["UploadsRemoveMsg"]}");
        return Task.FromResult(true);
    }
}
